package com.acegear.horizon.domain.models.jpa;

import com.fasterxml.jackson.annotation.JsonIgnore;

import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

/**
 * Created by wangsike on 2016/12/22.
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
public class AGDaily {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @JsonIgnore
    private Long id;

    @Column(unique = true)
    private Long dailyId;

    @Column
    private Long date;

    @Column
    private Boolean pushed;

    @Column
    private String background;

    @OneToMany(cascade = CascadeType.ALL)
    private List<AGDailyFeed> feeds;

    @CreatedDate
    @Column
    private Long createAt;

    @LastModifiedDate
    @Column
    private Long updateAt;

    public AGDaily() {

    }

    public AGDaily(Long dailyId, Long date, Boolean pushed, String background, List<AGDailyFeed> feeds) {
        this.dailyId = dailyId;
        this.date = date;
        this.pushed = pushed;
        this.background = background;
        this.feeds = feeds;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getDailyId() {
        return dailyId;
    }

    public void setDailyId(Long dailyId) {
        this.dailyId = dailyId;
    }

    public Long getDate() {
        return date;
    }

    public void setDate(Long date) {
        this.date = date;
    }

    public Boolean getPushed() {
        return pushed;
    }

    public void setPushed(Boolean pushed) {
        this.pushed = pushed;
    }

    public String getBackground() {
        return background;
    }

    public void setBackground(String background) {
        this.background = background;
    }

    public List<AGDailyFeed> getFeeds() {
        return feeds;
    }

    public void setFeeds(List<AGDailyFeed> feeds) {
        this.feeds = feeds;
    }

    public Long getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Long createAt) {
        this.createAt = createAt;
    }

    public Long getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Long updateAt) {
        this.updateAt = updateAt;
    }

    public void update(AGDaily other) {
        date = other.getDate();
        pushed = other.getPushed();
        background = other.getBackground();
        feeds = other.getFeeds();
    }
}
